<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工程信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>国别：</label>
                                <select name="countryType" th:with="type=${@dict.getType('country_list')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>工程日期： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addOptions()" shiro:hasPermission="price:projectnew:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="editOptions()" shiro:hasPermission="price:projectnew:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="price:projectnew:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="price:projectnew:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('price:projectnew:edit')}]];
        var removeFlag = [[${@permission.hasPermi('price:projectnew:remove')}]];
        var types = [[${@dict.getType('currency_type')}]];
        var status_dict = [[${@dict.getType('project_status')}]];
        var countryTypeDatas = [[${@dict.getType('country_list')}]];
        var prefix = ctx + "price/projectnew";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "工程信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'name',
                    title: '工程名称'
                },
                {
                    field: 'countryType',
                    title: '国别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(countryTypeDatas, value);
                    }
                },
                {
                    field: 'chineseWorkerUnitPrice',
                    title: '中国工人工日单价'
                },
                {
                    field: 'foreignWorkerUnitPrice',
                    title: '外国工人工日单价'
                },
                {
                    field: 'laborRatio',
                    title: '中外用工比'
                },
                {
                    field: 'fixedUnitPrice',
                    title: '定额工日单价'
                },
                {
                    field: 'actualUnitPrice',
                    title: '实际工日单价'
                },
                {
                    field: 'efficiencyRatio',
                    title: '中外工效比'
                },
                {
                    field: 'settleCurrencyType',
                    title: '结算货币类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(types, value);
                    }
                },
                {
                    field: 'result',
                    title: '计算结果'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(status_dict, value);
                    }
                },
                {
                    field: 'createBy',
                    title: '创建人'
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    visible: false
                },
                {
                    field: 'updateBy',
                    title: '修改人'
                },
                {
                    field: 'updateTime',
                    title: '修改时间',
                    visible: false
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if([[${userId}]] == row.createBy || [[${admin}]]){
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editOptions(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function addOptions(){
            var _btn = ['<i class="fa fa-check"></i> 暂存','<i class="fa fa-check" ></i> 保存','<i class="fa fa-check"></i> 发布', '<i class="fa fa-close"></i> 关闭'];
            var options = {
                title: '添加',
                url: prefix + "/add",
                btn: _btn,
                width: 1100,
                height: 630,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(1,index, layero);
                },
                btn2:function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(2,index, layero);
                    return false;
                },
                btn3:function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(3,index, layero);
                    return false;
                }
            };
            $.modal.openOptions(options);
        }

        function editOptions(id){
            table.set();
            var url = "";
            if($.common.isEmpty(id) && table.options.type == table_type.bootstrapTreeTable) {
                var row = $("#" + table.options.id).bootstrapTreeTable('getSelections')[0];
                if ($.common.isEmpty(row)) {
                    $.modal.alertWarning("请至少选择一条记录");
                    return;
                }
                url = table.options.updateUrl.replace("{id}", row[table.options.uniqueId]);
                $.modal.open("修改" + table.options.modalName, url,1100,630);
            } else {
                url = $.operate.editUrl(id);
            }

            var _btn = ['<i class="fa fa-check"></i> 暂存','<i class="fa fa-check" ></i> 保存','<i class="fa fa-check"></i> 发布', '<i class="fa fa-close"></i> 关闭'];
            var options = {
                title: '修改',
                url: url,
                btn: _btn,
                width: 1100,
                height: 630,
                btn2:function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(2,index, layero);
                    return false;
                },
                btn3:function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(3,index, layero);
                    return false;
                },
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(1,index, layero);
                }
            };
            $.modal.openOptions(options);
        }

    </script>
</body>
</html>